<template>
  <div class="main">
    <div class="main-search">
      <el-form :model="menuForm">
        <el-row :gutter="15">
          <el-col :span="5">
            <el-form-item label="" prop="type">
              <el-select
                v-model="menuForm.province"
                @chang="provinceChange"
                placeholder="省"
                clearable
              >
                <el-option
                  v-for="item in dicts.system_menu_type"
                  :key="item.v"
                  :label="item.k"
                  :value="item.v"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5"
            ><el-form-item label="" prop="type">
              <el-select v-model="menuForm.city" @change="cityChange" placeholder="市" clearable>
                <el-option
                  v-for="item in dicts.system_menu_type"
                  :key="item.v"
                  :label="item.k"
                  :value="item.v"
                />
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="5">
            <el-form-item label="" prop="type">
              <el-select
                v-model="menuForm.district"
                @change="districtChange"
                placeholder="区、县"
                clearable
              >
                <el-option
                  v-for="item in dicts.system_menu_type"
                  :key="item.v"
                  :label="item.k"
                  :value="item.v"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="main-map">
      <map-view
        @update:handleClickName="updateHandleClickName"
        @updateDialogVisible="handleDialogVisible"
      ></map-view>
    </div>
    <dialogInfo
      v-if="dialogVisible"
      v-model:handleClickName="handleClickName"
      v-model:dialogVisible="dialogVisible"
    ></dialogInfo>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, toRefs, watch, onMounted, watchEffect } from 'vue'
import mapView from '@components/map/index.vue'

import dialogInfo from '@components/dialog/index.vue'

const state = reactive({
  menuForm: {
    province: '',
    city: '',
    district: '',
    provinceList: [],
    cityceList: [],
    districtList: []
  },
  dialogVisible: false,
  handleClickId: '',
  handleClickName: ''
})

const { menuForm, dialogVisible, handleClickId, handleClickName } = toRefs(state)
const provinceChange = (e) => {
  menuForm.value.city = ''
  menuForm.value.district = ''
}
const cityChange = (e) => {
  menuForm.value.district = ''
}
watchEffect((value) => {
  console.log(value, 'value')
})
const districtChange = (e) => {}

const handleDialogVisible = (value) => {
  dialogVisible.value = value
}
const updateHandleClickName = (value) => {
  handleClickName.value = value
}
</script>
<style lang="scss" scoped>
.main {
  height: 90vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  // align-items: center;
}
.main-search {
  padding: 10px 10px 0 10px;
  background: #edf3f3;
}
.main-map {
  flex: 1;
}
</style>
